package com.example.goandpaytthebill.Tool;

import android.os.CountDownTimer;
import android.widget.TextView;

public class TimeCount extends CountDownTimer {
    private TextView button;
    private String tickText;
    private String finishText;

    /**
     * @param millisInFuture    倒计时总时长
     * @param countDownInterval 倒计时单位 毫秒.
     */
    public TimeCount(long millisInFuture, long countDownInterval,
                     TextView button, String tickText, String finishText) {
        super(millisInFuture, countDownInterval);
        this.button = button;
        this.tickText=tickText;
        this.finishText=finishText;
    }

//    public TimeCount(long millisInFuture, long countDownInterval, CountDownButton countDownButton, String mTickText, String mFinishText) {
//        super(millisInFuture, countDownInterval, countDownButton, mTickText, mFinishText);
//    }


    @Override
    public void onTick(long millisUntilFinished) {
        button.setText(millisUntilFinished / 1000 + tickText);
        button.setEnabled(false);
    }

    @Override
    public void onFinish() {
        button.setEnabled(true);
        button.setText(finishText);
    }
}